﻿using J.Model;
using J.ProductSet.Application.Command.ProductCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;

namespace J.ProductSet.Controllers
{
    /// <summary>
    /// 商品(写)
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductController : ControllerBase
    {
        private readonly IMediator _mediator;
        public ProductController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 商品添加
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ProductPost(ProductPostCommand command)
        {
            return Ok(await _mediator.Send(command));
        }
        /// <summary>
        /// 商品删除
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ProductDelete(ProductDeleteCommand command)
        {
            return Ok(await _mediator.Send(command));
        }
        /// <summary>
        /// 商品修改
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ProductUpdate(ProductUpdateCommand command)
        {
            return Ok(await _mediator.Send(command));
        }
        [HttpPost]
        public async Task<IActionResult> ProductUnmount(ProductUnmountCommand command)
        {
            return Ok(await _mediator.Send(command));
        }
    }
}
